import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueCookie from 'vue-cookie'
import VueLazyLoad from 'vue-lazyload'
import { Message } from 'element-ui'

Vue.config.productionTip = false

const mock = false
if (mock) {
  require('./mock/api')
}



axios.defaults.baseURL = '/api',
  axios.defaults.timeout = 8000,

  axios.interceptors.response.use(function (response) {
    let res = response.data
    if (res.status == 0) {
      return res.data
    } else if (res.status == 10) {
      if (location.hash != '#/index') {
        window.location.href = '/#/login';
      }
      return Promise.reject(res)
    } else {
      Message.warning(res.msg)
      return Promise.reject(res)
    }
  })


Vue.use(VueAxios, axios);
Vue.use(VueCookie)
Vue.use(VueLazyLoad, {
  loading: '/imgs/loading-svg/loading-bars.svg'
})

Vue.prototype.$message = Message


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

